<template>
  <div class="radar-chart-container">
    <v-chart
      :option="chartOption"
      :autoresize="true"
      style="height: 300px; width: 100%;"
    />
  </div>
</template>

<script>
import { use } from 'echarts/core';
import { CanvasRenderer } from 'echarts/renderers';
import { RadarChart } from 'echarts/charts';
import { TitleComponent, LegendComponent, TooltipComponent } from 'echarts/components';
import VChart from 'vue-echarts';

// 按需注册 ECharts 组件
use([CanvasRenderer, RadarChart, TitleComponent, LegendComponent, TooltipComponent]);

export default {
  name: 'RadarChart',
  components: {
    VChart
  },
  data() {
    return {
      chartOption: {
        title: {
          text: '能力评估',
          left: 'center',
          top: '0px', // 调整到顶部，增加5px间距
          textStyle: {
            color: '#333',
            fontSize: 16,
            fontWeight: 'bold'
          }
        },
        legend: {
          data: ['当前能力','目标能力'],
          bottom: '5px',
          left: 'center',
          textStyle: {
            color: '#666',
            fontSize: 12
          },
          itemWidth: 12,
          itemHeight: 12
        },
        tooltip: {
          trigger: 'item'
        },
        radar: {
          shape: 'circle',
          radius: '60%',
          center: ['50%', '52%'],
          name: {
            textStyle: {
              color: '#666',
              fontSize: 12,
              fontWeight: 'normal',
              padding: [2, 2]
            }
          },
          axisLine: {
            lineStyle: {
              color: 'rgba(0, 0, 0, 0.1)'
            }
          },
          splitLine: {
            lineStyle: {
              color: 'rgba(0, 0, 0, 0.1)'
            }
          },
          splitArea: {
            show: false
          },
          indicator: [
            { 
              name: '语法准确性', 
              max: 100
            },
            { 
              name: '逻辑连贯性', 
              max: 100
            },
            { 
              name: '风格一致性', 
              max: 100
            }
          ]
        },
        series: [
          {
            name: '能力评估',
            type: 'radar',
            emphasis: {
              lineStyle: {
                width: 4
              }
            },
            data: [
              {
                value: [70, 80, 40],
                name: '当前能力',
                symbolSize: 6,
                areaStyle: {
                  color: 'rgba(64, 158, 255, 0.4)'
                },
                lineStyle: {
                  color: '#409EFF',
                  width: 2
                },
                itemStyle: {
                  color: '#409EFF'
                }
              },
              {
                value: [100, 100, 100],
                name: '目标能力',
                symbolSize: 6,
                areaStyle: {
                  color: 'rgba(255, 193, 7, 0.2)'
                },
                lineStyle: {
                  color: '#FFC107',
                  width: 2,
                  type: 'dashed'
                },
                itemStyle: {
                  color: '#FFC107'
                }
              }
            ]
          }
        ]
      }
    };
  }
};
</script>

<style scoped>
.radar-chart-container {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  height: 100%;
  box-sizing: border-box;
}
</style>